package bb.lanxing.model.json;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;
import com.orm.dsl.Ignore;
import com.umeng.socialize.net.utils.SocializeProtocolConstants;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.List;

import bb.lanxing.util.JsonUtil;
import bb.lanxing.util.MedalUtil;


public class WorkoutComment implements Serializable, Parcelable {
    public static final Creator<WorkoutComment> CREATOR = new Creator<>() {
        @Override
        public WorkoutComment createFromParcel(Parcel parcel) {
            return new WorkoutComment(parcel);
        }

        @Override
        public WorkoutComment[] newArray(int i) {
            return new WorkoutComment[i];
        }
    };
    private String content;
    private long id;
    private String image;
    @JSONField(name = "informed_user_id")
    private long informedId;
    @JSONField(name = "informed_pic_url")
    private String informedImageUrl;
    @JSONField(name = "informed_user_name")
    private String informedName;
    @JSONField(name = "ulevel")
    private int level;
    @JSONField(name = "license_number_color")
    private String licenseNumberColor;
    @JSONField(name = "license_number_skin")
    private String licenseNumberSkin;
    @Ignore
    private String medalSmall;
    @JSONField(name = "pic_url")
    private String picUrl;
    @JSONField(name = "license_number")
    private String plateNum;
    @JSONField(name = "pro_name")
    private String proName;
    private long time;
    @JSONField(name = "medal_small")
    private List<UserAvatarMedal> userAvatarMedals;
    @JSONField(name = "user_id")
    private long userId;
    @JSONField(name = "user_name")
    private String userName;
    @JSONField(name = "workout_id")
    private long workoutId;

    @Override
    public int describeContents() {
        return 0;
    }

    public WorkoutComment() {
    }

    public WorkoutComment(JSONObject jSONObject) throws JSONException {
        JSONArray arrayValue;
        setId(jSONObject.getLong("id"));
        setWorkoutId(jSONObject.getLong("workout_id"));
        setUserId(jSONObject.getLong("user_id"));
        setUserName(jSONObject.getString("user_name"));
        setContent(jSONObject.getString("content"));
        setPicUrl(jSONObject.getString("pic_url"));
        setImage(jSONObject.getString(SocializeProtocolConstants.IMAGE));
        setTime(jSONObject.getLong("time"));
        setInformedId(jSONObject.getLong("informed_user_id"));
        setInformedName(jSONObject.getString("informed_user_name"));
        setInformedImageUrl(jSONObject.getString("informed_pic_url"));
        setLevel(JsonUtil.getIntegerValue("ulevel", jSONObject));
        setLicenseNumberColor(JsonUtil.getStringValue("license_number_color", jSONObject));
        setLicenseNumberSkin(JsonUtil.getStringValue("license_number_skin", jSONObject));
        if (jSONObject.has("medal_small") && (arrayValue = JsonUtil.getArrayValue("medal_small", jSONObject)) != null) {
            List<UserAvatarMedal> userAvatorMedalInfo = MedalUtil.getUserAvatorMedalInfo(arrayValue);
            if (userAvatorMedalInfo != null) {
                String str = "";
                for (int i = 0; i < userAvatorMedalInfo.size(); i++) {
                    str = i == userAvatorMedalInfo.size() - 1 ? str + userAvatorMedalInfo.get(i).getUrl() : str + userAvatorMedalInfo.get(i).getUrl() + ";";
                }
                setMedalSmall(str);
            } else {
                setMedalSmall(null);
            }
            setUserAvatarMedals(userAvatorMedalInfo);
        }
        setPlateNum(JsonUtil.getStringValue("license_number", jSONObject));
        setProName(JsonUtil.getStringValue("pro_name", jSONObject));
    }

    public String getLicenseNumberSkin() {
        return this.licenseNumberSkin;
    }

    public void setLicenseNumberSkin(String str) {
        this.licenseNumberSkin = str;
    }

    public String getLicenseNumberColor() {
        return this.licenseNumberColor;
    }

    public void setLicenseNumberColor(String str) {
        this.licenseNumberColor = str;
    }

    public long getId() {
        return this.id;
    }

    public long getWorkoutId() {
        return this.workoutId;
    }

    public long getUserId() {
        return this.userId;
    }

    public int getLevel() {
        return this.level;
    }

    public void setLevel(int i) {
        this.level = i;
    }

    public String getMedalSmall() {
        return this.medalSmall;
    }

    public void setMedalSmall(String str) {
        this.medalSmall = str;
    }

    public List<UserAvatarMedal> getUserAvatarMedals() {
        return this.userAvatarMedals;
    }

    public void setUserAvatarMedals(List<UserAvatarMedal> list) {
        this.userAvatarMedals = list;
    }

    public String getUserName() {
        return this.userName;
    }

    public String getContent() {
        return this.content;
    }

    public String getPicUrl() {
        return this.picUrl;
    }

    public String getImage() {
        return this.image;
    }

    public long getTime() {
        return this.time;
    }

    public long getInformedId() {
        return this.informedId;
    }

    public String getInformedName() {
        return this.informedName;
    }

    public String getInformedImageUrl() {
        return this.informedImageUrl;
    }

    public void setId(long j) {
        this.id = j;
    }

    public void setWorkoutId(long j) {
        this.workoutId = j;
    }

    public void setUserId(long j) {
        this.userId = j;
    }

    public void setUserName(String str) {
        this.userName = str;
    }

    public void setContent(String str) {
        this.content = str;
    }

    public void setPicUrl(String str) {
        this.picUrl = str;
    }

    public void setImage(String str) {
        this.image = str;
    }

    public void setTime(long j) {
        this.time = j;
    }

    public void setInformedId(long j) {
        this.informedId = j;
    }

    public void setInformedName(String str) {
        this.informedName = str;
    }

    public void setInformedImageUrl(String str) {
        this.informedImageUrl = str;
    }

    public String getPlateNum() {
        return this.plateNum;
    }

    public void setPlateNum(String str) {
        this.plateNum = str;
    }

    public String getProName() {
        return this.proName;
    }

    public void setProName(String str) {
        this.proName = str;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeLong(this.id);
        parcel.writeLong(this.workoutId);
        parcel.writeLong(this.userId);
        parcel.writeString(this.userName);
        parcel.writeInt(this.level);
        parcel.writeTypedList(this.userAvatarMedals);
        parcel.writeString(this.medalSmall);
        parcel.writeString(this.content);
        parcel.writeString(this.picUrl);
        parcel.writeString(this.image);
        parcel.writeLong(this.time);
        parcel.writeLong(this.informedId);
        parcel.writeString(this.informedName);
        parcel.writeString(this.informedImageUrl);
        parcel.writeString(this.plateNum);
        parcel.writeString(this.proName);
        parcel.writeString(this.licenseNumberColor);
        parcel.writeString(this.licenseNumberSkin);
    }

    protected WorkoutComment(Parcel parcel) {
        this.id = parcel.readLong();
        this.workoutId = parcel.readLong();
        this.userId = parcel.readLong();
        this.userName = parcel.readString();
        this.level = parcel.readInt();
        this.userAvatarMedals = parcel.createTypedArrayList(UserAvatarMedal.CREATOR);
        this.medalSmall = parcel.readString();
        this.content = parcel.readString();
        this.picUrl = parcel.readString();
        this.image = parcel.readString();
        this.time = parcel.readLong();
        this.informedId = parcel.readLong();
        this.informedName = parcel.readString();
        this.informedImageUrl = parcel.readString();
        this.plateNum = parcel.readString();
        this.proName = parcel.readString();
        this.licenseNumberColor = parcel.readString();
        this.licenseNumberSkin = parcel.readString();
    }
}
